import {createContext,useState,useContext,useEffect} from 'react'

const AuthContext = createContext();

export const useAuth = ()=>{
    return useContext(AuthContext);
}

const AuthProvider = (props)=>{
    const [isLogin,setIsLogin] = useState(false);
    useEffect(()=>{
            setIsLogin(sessionStorage.getItem('isLogin')||false)   
      },[])

    return <AuthContext.Provider value={{isLogin,setIsLogin}}>
        {props.children}
    </AuthContext.Provider>
}
export default AuthProvider;